#pragma once

#include "Game/Process/RenderProcess.h"
#include "Render/Texture/Picture2DTexture.h"
#include "Render/Texture/RenderTarget.h"
#include "Render/Tradition/RHIRenderPass.h"
#include "Render/Tradition/GraphicsPipeline.h"
#include "Render/Texture/ColorRenderTarget.h"
#include "Render/Texture/CubemapTexture.h"
#include "Render/Texture/DepthRenderTarget.h"
#include "Render/Shader/RHIDescriptor.h"
#include "Render/Tradition/RHIFramebuffer.h"
#include "LocalEntity.h"

class LocalScene;

class DeferredProcess : public RenderProcess
{
	DECLARE_PROCESS(DeferredProcess)

	struct Ubo {
		glm::mat4 cameraView;
		glm::mat4 lightProj;
		glm::mat4 lightView;
		glm::vec4 lightData;
		glm::vec3 lightDir; 
		int32 debugIndex;
	};

public:

	int32 mDebugIndex;

	LocalScene* mLocalScene;

protected:

	virtual void OnInit() override;

	virtual void OnTick(float deltaTime) override;

	virtual void OnResize() override;

protected:

	std::array<glm::vec4, VPL_NUM> mSampleCoordsAndWeights;

	RefCountPtr<RHIBuffer> mUboBuffer;

	RefCountPtr<RHIBuffer> mSampleCoordsAndWeightsBuffer;

	RefCountPtr<RHISampler> mCommonSampler;

	RefCountPtr<RHISampler> mRsmSampler;

	DescriptorMask mDescriptorMask;

	RefCountPtr<RHIDescriptor> mDescriptor;

	RefCountPtr<GraphicsPipeline> mPipeline;

	RefCountPtr<RHIRenderPass> mRenderPass;

	RefCountPtr<RHIFrameBuffer> mFrameBuffer;

	RefCountPtr<ColorRenderTarget> mColorRenderTarget;

	RefCountPtr<DepthRenderTarget> mDepthRenderTarget;

};
